# -*- coding: utf-8 -*-

import os
from datetime import datetime
import logging

from flask import request

from mpdev.gzone_loader import current_room, current_user


class BaseMedia(object):
    path_component = ()
    media_root = ''

    def get_file_path(self, path, with_root):
        if with_root:
            path = os.path.join(self.media_root, path)
        return path

    def get_path_components(self, *args):
        return self.path_component + args


class ImageMedia(BaseMedia):
    path_component_thumb = 'thumbnail'


class FileMedia(BaseMedia):
    pass


class MomentImage(ImageMedia):
    path_component = ('images', 'moment')

    def get_file_path(self, filename, with_root=False):
        path = self.get_path_components(
            current_room.id,
            current_user.openid,
            filename
        )
        path_thumb = self.get_path_components(
            current_room.id,
            current_user.openid,
            self.path_component_thumb,
            filename
        )
        return super(MomentImage, self).get_file_path(path, with_root), \
               super(MomentImage, self).get_file_path(path_thumb, with_root)


class GroupAlbumImage(ImageMedia):
    pass


class GroupImage(ImageMedia):
    pass


class GroupFile(FileMedia):
    pass


class AccountBannerImage(ImageMedia):
    pass


class AnnouncementImage(ImageMedia):
    pass
